package com.example.hxds.bff.customer.service.impl;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.map.MapUtil;
import com.example.hxds.bff.customer.controller.form.InsertCommentForm;
import com.example.hxds.bff.customer.controller.form.LoginForm;
import com.example.hxds.bff.customer.controller.form.RegisterNewCustomerForm;
import com.example.hxds.bff.customer.feign.CustomerServiceApi;
import com.example.hxds.bff.customer.service.CustomerService;
import com.example.hxds.common.util.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @Author XUYANG
 * @Date 2024-03-16 15:31
 */
@Service
public class CustomerServiceImpl implements CustomerService {
    @Resource
    private CustomerServiceApi customerServiceApi;
    @Override
    public long registerNewCustomer(RegisterNewCustomerForm form) {
        R r=customerServiceApi.registerNewCustomer(form);
        long userId= Convert.toLong(r.get("userId"));
        return userId;
    }

    @Override
    public Long login(LoginForm form) {
        R login = customerServiceApi.login(form);
        String userId= MapUtil.getStr(login,"userId");
        if (userId!=null){
            return Convert.toLong(userId);
        }
        return null;
    }

}
